# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=py3-pyside2
pkgver=5.15.11
pkgrel=0
pkgdesc="Enables the use of Qt5 APIs in Python applications"
url="https://doc.qt.io/qtforpython-5/"
# armhf blocked by shiboken2
arch="all !armhf"
license="LGPL-3.0-only AND GPL-2.0-only"
_llvmver=15
depends="py3-shiboken2"
makedepends="
	clang$_llvmver-dev
	cmake
	libshiboken2-dev
	qt5-qt3d-dev
	qt5-qtbase-dev
	qt5-qtcharts-dev
	qt5-qtdatavis3d-dev
	qt5-qtdeclarative-dev
	qt5-qtlocation-dev
	qt5-qtmultimedia-dev
	qt5-qtquickcontrols2-dev
	qt5-qtremoteobjects-dev
	qt5-qtscript-dev
	qt5-qtscxml-dev
	qt5-qtsensors-dev
	qt5-qtserialport-dev
	qt5-qtspeech-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	qt5-qtwebchannel-dev
	qt5-qtwebsockets-dev
	qt5-qtx11extras-dev
	qt5-qtxmlpatterns-dev
	samurai
	shiboken2
	py3-setuptools
	py3-zope-event
	"
case "$CARCH" in
armv7|aarch64|x86|x86_64)
	makedepends="$makedepends qt5-qtwebengine-dev"
	;;
esac
subpackages="$pkgname-dev"
source="https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-$pkgver-src/pyside-setup-opensource-src-$pkgver.tar.xz"
builddir="$srcdir/pyside-setup-opensource-src-$pkgver"
options="!check" # Tests fail

build() {
	export LLVM_INSTALL_DIR=/usr/lib/llvm$_llvmver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DPYTHON_EXECUTABLE=/usr/bin/python3 \
		-DBUILD_TESTS=OFF \
		sources/pyside2
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Install egg info
	export PATH="/usr/lib/qt5/bin:$PATH"
	python3 setup.py egg_info --build-type=pyside2
	pythonpath="$(python3 -c "from sysconfig import get_path; print(get_path('platlib'))")"
	cp -r PySide2.egg-info "$pkgdir/$pythonpath"
}

sha512sums="
377b3f6a793313cf7f5bea0dcef6630bac32d79b247e213d0b1b719805b35692aa8dd9a8896c75c6266f05af38809f574051d64b1a2f958a48c90167feccfb91  pyside-setup-opensource-src-5.15.11.tar.xz
"
